package com.changgou.good.controller;

import com.changgou.good.service.SkuService;
import com.changgou.goods.pojo.Sku;
import entity.Result;
import entity.StatusCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/search")
@CrossOrigin
public class SkuController {

    @Autowired
    private SkuService skuService;

    @GetMapping
    public Map search(@RequestParam(required = false) Map searchMap){
        // search by name
        return skuService.search(searchMap);
    }

    @PostMapping(value = "/sku" )
    public Result<List<Sku>> findList(@RequestBody(required = false) Sku sku){
        return new Result<>(true, StatusCode.OK, "Success", skuService.findList(sku));
    }
}
